package com.sk.commonadapter_android;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.LinearLayout;

import com.sk.commonadapter_android.adapter.CommonRecyclerViewAdapter;
import com.sk.commonadapter_android.adapter.CommonViewHolder;

import java.util.ArrayList;
import java.util.List;

public class CommonRecyclerviewActivity extends AppCompatActivity {
    private RecyclerView mRecyclerView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_common_recyclerview);
        mRecyclerView = (RecyclerView) findViewById(R.id.recyclerview);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        List<String> mData=new ArrayList<>();
        for (int i=0;i<20;i++)
            mData.add("我是内容:"+i);
        mAdapter.addAll(mData);
        mRecyclerView.addItemDecoration(new DividerItemDecoration(this, LinearLayout.VERTICAL));
        mRecyclerView.setAdapter(mAdapter);
    }

    private CommonRecyclerViewAdapter<String> mAdapter = new CommonRecyclerViewAdapter<String>(this, R.layout.item_common_recyclerview) {
        @Override
        public void convert(CommonViewHolder holder, String item, int position) {
            holder.setTextView(R.id.tv_comm_value, item);
        }
    };
}
